﻿@using OBUCare.Core.Models
@using OBUCare.Web.Models
@using OBUCare.Web.Infrastructure

<link href="../../Content/tableCss.css" rel="stylesheet" type="text/css" />
<table width="100%">
    <tr>
        <td align="center">
            <span class="pTitle">维护维修日报汇总</span>
        </td>
    </tr>
    <tr>
        <td>&nbsp;
        </td>
    </tr>
    <tr>
        <td align="center">
            @Html.Partial("_RepairDailySearch")
        </td>
    </tr>
    <tr>
        <td>
            <span style="float: right; font-size: 13px">金额单位：元</span>
        </td>
    </tr>
    <tr>
        <td style="font-size: 13px">合计  一口价维修费用：<span id="spanOneRepair">0</span>&nbsp;退还押金：<span id="spanReturnDeposit">0</span>&nbsp;收取押金：<span id="spanCollectsDeposit">0</span>&nbsp;维修费用：<span id="spanRepairObu">0</span>&nbsp;背胶销售：<span id="spanIssueSpareTape">0</span>&nbsp;底座销售：<span id="spanIssueBase">0</span>&nbsp;服务费：<span id="spanRepairServiceFee">0</span>&nbsp;交易总金额：<span id="spanSUM_PRICE">0</span></td>
    </tr>
    <tr>
        <td align="center">
            @(Html.Telerik().Grid<RepairDailyViewModel>()
        .Name("Grid")
        .Sortable(sorting => sorting.SortMode(GridSortMode.SingleColumn))
        .DataBinding(dataBinding => dataBinding
            .Ajax()
                    .Select("ListRepairDaily", "Report")
                    )
        .Columns(columns =>
        {
            columns.Bound(o => o.RECORD_DATE).Format("{0:yyyy-MM-dd}").Width("9%");
            columns.Bound(o => o.AGENT_NAME).Width("9%");
            columns.Bound(o => o.OPERATOR_NAME).Width("9%");
            columns.Bound(o => o.ReturnDeposit).Width("9%");
            columns.Bound(o => o.CollectsDeposit).Width("9%");
            columns.Bound(o => o.RepairObu).Width("9%");
            columns.Bound(o => o.IssueSpareTape).Width("9%");
            columns.Bound(o => o.IssueBase).Width("9%");
            columns.Bound(o => o.RepairServiceFee).Width("8%");
            columns.Bound(o => o.OneRepair).Width("11%");
            columns.Bound(o => o.SUM_PRICE).Width("9%");
        }).TableHtmlAttributes(new { @style = "width:150%" })
        .ClientEvents(events =>
        {
            events.OnError("onError");
            events.OnDataBinding("onDataBinding");
        })
        .Footer(true)
        .Pageable(paging =>
        {
            paging.Style(CommonStyleForUI.Grid_PageStyle)
            .Position(CommonStyleForUI.Grid_PagePosition)
            .PageTo(CommonStyleForUI.Grid_CurrentPage)
            .PageSize(CommonStyleForUI.Grid_PageSize, new int[] { 10, 20, 50, 100, 200 });
        })
                    //.Resizable(resizing => resizing.Columns(true))
        .Scrollable(scroll => scroll.Height(CommonStyleForUI.Grid_Height))
                    //.Selectable()
)
        </td>
    </tr>
</table>
<script type="text/javascript">
    function onError(e) {
        //debugger;
        e.preventDefault();
        /*if (e.XMLHttpRequest.status == "505")
        alert("系统字段不允许删除");
        else if (e.XMLHttpRequest.status == "506")
        alert("系统表不允许删除");
        else*/
        alert(e.XMLHttpRequest.getResponseHeader("message"));
    }

    var index = 0;

    function onDataBinding(e) {
        var strSearchSql = $('#searchSql').val();
        //grid自带的查询事件时，将其取消，只保留手动执行的查询
        if (strSearchSql.StringIsNullOrEmpty())
            e.preventDefault();

        var grid = $('#Grid').data('tGrid')
        index = (grid.currentPage - 1) * grid.pageSize;
        e.data = {
            // the key ("category") specifies the variable name of the action method which will contain the specified value
            searchSql: $('#searchSql').val()
        };
    }
</script>
